package com.ct.controller;


import com.ct.R.Result.Result;
import com.ct.R.Result.ResultEnum.ResultCodeEnum;
import com.ct.R.exception.ApiException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单模块
 */
@RestController
public class OrderController {

    /**
     * 下单方法
     * @param pid
     * @return
     */
    @PostMapping("/make/order1")
    public Result makeOrder1(@RequestParam("pid") Long pid){
        if (pid.equals(0L)){
            throw new RuntimeException("该用户已经被禁止了");
        }
        return Result.success("ok");
    }


    /**
     * 下单方法
     * @param pid
     * @return
     */
    @PostMapping("/make/order2")
    public Result makeOrder2(@RequestParam("pid") Long pid){
        if (pid.equals(0L)){
            throw new ApiException(ResultCodeEnum.LIMITE_SERVER_ERROR);
        }
        return Result.success("ok");
    }
}
